﻿/**************************************************************
 * Copyright Eastmoney Corporation. All rights reserved.
 * 
 * Author: guitao(guitao@eastmoney.com) 
 * Create Date: 2020/6/12 13:34:38
 * Description:
 *          
 * Revision History:
 *      Date         Author               Description
 *              
***************************************************************/

using gt.EventBus.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace gt.EventBus.Abstractions
{
    /// <summary>
    /// 通用事件处理Handler
    /// </summary>
    public interface IIntegrationEventHandler
    {
    }

    public interface IIntegrationEventHandler<in TIntegrationEvent> : IIntegrationEventHandler
        where TIntegrationEvent : IntegrationEvent
    {
        Task Handle(TIntegrationEvent @event);
    }


    public class Animal
    { }
    public class Dog : Animal
    { }

    public class Test
    {
        void Convert()
        {
            var dog = new Dog();
            Animal a = dog;

            //error
            //Dog d2 = a;

            IList<Dog> dogs = new List<Dog>();
            //error List<Animal> anis = dogs;

            //IEnumerable out 协变，
            IEnumerable<Dog> d = dogs;
            IEnumerable<Animal> anis = d;

            //Action<Dog> d_action = (s) => { };
            //Action<Animal> a_action = d_action;

            //逆变
            Action<Animal> a_action = (s) => { };
            Action<Dog> d_action = a_action;

            //error 逆变 协变组合
            //Action<List<Animal>> aa_action = (s) => { };
            //Action<List<Dog>> dd_action = aa_action;

            Action<IEnumerable<Animal>> aa_action = (s) => { };
            Action<IEnumerable<Dog>> dd_action = aa_action;
        }
    }
}
